<template>
  <div class="scroll">
    <example-card title="弹框提示" url="http://element.eleme.io/#/zh-CN/component/message-box">
      <div>
        <el-button type="text" @click="alert">提示</el-button>
        <el-button type="text" @click="confirm">删除</el-button>
        <el-button type="text" @click="prompt">请输入邮箱</el-button>
      </div>
    </example-card>
  </div>
</template>

<script>
  export default {
    name: "notice_message-box_view",
    methods: {
      alert() {
        this.$alert('这是一段内容', '标题名称', {
          confirmButtonText: '确定',
          callback: action => {
            this.$message({
              type: 'info',
              message: `action: ${ action }`
            });
          }
        });
      },
      confirm() {
        this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$message({
            type: 'success',
            message: '删除成功!'
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });
        });
      },
      prompt() {
        this.$prompt('请输入邮箱', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          inputPattern: /[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/,
          inputErrorMessage: '邮箱格式不正确'
        }).then(({ value }) => {
          this.$message({
            type: 'success',
            message: `你的邮箱是: ${value}`
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '取消输入'
          });
        });
      }
    }
  };
</script>

<style scoped>

</style>
